package com.RMP
{
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import com.greensock.*;

    public class BookmarksHelp extends Sprite
    {
        var fadeSpeed:Number;
        public var coverSprite:Sprite;
        var bigField1:BigField;
        var bigField2:BigField;
        var myRoot:MovieClip;
        var longText:LongText;
        var myLink:BookmarkSaveLink;
        var styler:StyleSheet;

        public function BookmarksHelp(param1:MovieClip, param2:Number) : void
        {
            visible = false;
            alpha = 0;
            myRoot = param1;
            fadeSpeed = param2;
            buildLongTitle();
            buildStyles();
            buildField();
            buildCoverSprite();
            myRoot.stage.addEventListener(Event.RESIZE, onResizer, false, 0, true);
            doResize();
            return;
        }

        function buildCoverSprite() : void
        {
            myLink = new BookmarkSaveLink();
            myLink.field1.field.text = myRoot.path + "www/#/bookmarks/browse/" + myRoot.myBookmarksID + "/";
            myLink.field1.field.addEventListener(FocusEvent.FOCUS_IN, focusInListener, false, 0, true);
            myLink.saveBtn.buttonMode = true;
            myLink.saveBtn.useHandCursor = true;
            myLink.saveBtn.addEventListener(MouseEvent.CLICK, saveBtnClick, false, 0, true);
            myLink.saveBtn.addEventListener(MouseEvent.ROLL_OVER, saveBtnRollOver, false, 0, true);
            myLink.saveBtn.addEventListener(MouseEvent.ROLL_OUT, saveBtnRollOut, false, 0, true);
            addChild(myLink);
            coverSprite = new Sprite();
            coverSprite.graphics.beginFill(16777215, 1);
            coverSprite.graphics.drawRect(0, 0, 1, 1);
            coverSprite.graphics.endFill();
            coverSprite.buttonMode = true;
            coverSprite.useHandCursor = false;
            coverSprite.alpha = 0;
            coverSprite.visible = false;
            addChild(coverSprite);
            return;
        }

        public function fadeOutShell() : void
        {
            visible = false;
            return;
        }

        function doResize() : void
        {
            if (coverSprite != null)
            {
                coverSprite.x = 0;
                coverSprite.y = Math.round(myRoot.headerH + 2 * (myRoot.unitH + myRoot.gutterH) - 5);
                coverSprite.width = 12 * (myRoot.unitW + myRoot.gutterW);
                coverSprite.height = 4 * (myRoot.unitH + myRoot.gutterH);
            }
            if (longText != null)
            {
                longText.x = Math.round(4 * (myRoot.unitW + myRoot.gutterW));
                longText.y = myRoot.headerH + (myRoot.unitH + myRoot.gutterH) - 4 * myRoot.unitW / 75;
                var _loc_1:* = myRoot.unitW / 75;
                longText.field.scaleY = myRoot.unitW / 75;
                longText.field.scaleX = _loc_1;
            }
            var _loc_1:* = myRoot.unitW / 75;
            bigField1.field.scaleY = myRoot.unitW / 75;
            bigField1.field.scaleX = _loc_1;
            bigField1.x = Math.round(4 * (myRoot.unitW + myRoot.gutterW) - 3 * myRoot.unitW / 75);
            bigField1.y = Math.round(myRoot.headerH + 2 * (myRoot.unitH + myRoot.gutterH) + -5 * myRoot.unitW / 75);
            var _loc_1:* = myRoot.unitW / 75;
            bigField2.field.scaleY = myRoot.unitW / 75;
            bigField2.field.scaleX = _loc_1;
            bigField2.x = Math.round(8 * (myRoot.unitW + myRoot.gutterW) - 3 * myRoot.unitW / 75);
            bigField2.y = Math.round(myRoot.headerH + 2 * (myRoot.unitH + myRoot.gutterH) + -5 * myRoot.unitW / 75);
            if (myLink != null)
            {
                var _loc_1:* = myRoot.unitW / 75;
                myLink.field1.field.scaleY = myRoot.unitW / 75;
                myLink.field1.field.scaleX = _loc_1;
                myLink.field1.inputBG.width = Math.round(6 * myRoot.unitW + 5 * myRoot.gutterW);
                myLink.field1.inputBG.height = Math.round(26 * myRoot.unitW / 75);
                var _loc_1:* = Math.round(6 * (myRoot.unitW + myRoot.gutterW));
                myLink.saveBtn.x = Math.round(6 * (myRoot.unitW + myRoot.gutterW));
                myLink.saveBG.x = _loc_1;
                var _loc_1:* = Math.round(myLink.field1.y);
                myLink.saveBtn.y = Math.round(myLink.field1.y);
                myLink.saveBG.y = _loc_1;
                var _loc_1:* = Math.round(80 * myRoot.unitW / 75);
                myLink.saveBtn.width = Math.round(80 * myRoot.unitW / 75);
                myLink.saveBG.width = _loc_1;
                var _loc_1:* = Math.round(26 * myRoot.unitW / 75);
                myLink.saveBtn.height = Math.round(26 * myRoot.unitW / 75);
                myLink.saveBG.height = _loc_1;
                myLink.mySave.x = myLink.saveBG.x + 3;
                myLink.mySave.y = myLink.saveBG.y + 1;
                var _loc_1:* = myRoot.unitW / 75;
                myLink.mySave.scaleY = myRoot.unitW / 75;
                myLink.mySave.scaleX = _loc_1;
                myLink.saveArrow.x = Math.round(myLink.saveBG.x + myLink.saveBG.width - 10 * myRoot.unitW / 75);
                myLink.saveArrow.y = Math.round(myLink.saveBG.y + 10 * myRoot.unitW / 75);
                myLink.x = Math.round(4 * (myRoot.unitW + myRoot.gutterW));
                myLink.y = Math.round(myRoot.headerH + 2 * myRoot.unitH + myRoot.gutterH - 8 * myRoot.unitW / 75 - myLink.height);
            }
            return;
        }

        function saveBtnClick(event:MouseEvent)
        {
            myRoot.bookmarkLightbox();
            return;
        }

        function buildField() : void
        {
            bigField1 = new BigField();
            bigField1.name = "bigField1";
            bigField1.field.antiAliasType = AntiAliasType.ADVANCED;
            bigField1.field.gridFitType = GridFitType.PIXEL;
            bigField1.field.selectable = true;
            bigField1.field.embedFonts = true;
            bigField1.field.multiline = true;
            bigField1.field.wordWrap = true;
            bigField1.field.styleSheet = styler;
            bigField1.alpha = 1;
            addChild(bigField1);
            bigField2 = new BigField();
            bigField2.name = "bigField2";
            bigField2.field.antiAliasType = AntiAliasType.ADVANCED;
            bigField2.field.gridFitType = GridFitType.PIXEL;
            bigField2.field.selectable = true;
            bigField2.field.embedFonts = true;
            bigField2.field.multiline = true;
            bigField2.field.wordWrap = true;
            bigField2.field.styleSheet = styler;
            bigField2.alpha = 1;
            addChild(bigField2);
            bigField1.field.htmlText = "<p><span class=\'myBold\'>Browse</span><br>Use the Bookmarks feature to save a custom set of images and pages you come across while viewing our site. " + "When you see the <span class=\'myBold\'>+</span> icon or Bookmarks link it means you can add that item to your Bookmark Set. You can remove an item from your Bookmark " + "Set at any time by clicking the <span class=\'myBold\'>-</span> icon. You can also reorder the images and pages in your Bookmark Set by clicking on the forward and backward " + "arrows.<br><br>" + "<span class=\'myBold\'>Share</span><br>You can email yourself, a friend or a colleague a link to your custom Bookmarks. This is also a great way to save your Bookmarks link in a safe location.</p>";
            bigField2.field.htmlText = "<p><span class=\'myBold\'>Clear</span><br>Clearing a Bookmark Set permanently removes all images and pages you have added. Please be aware there is " + "no undo for this action.<br><br><span class=\'myBold\'>Create New</span><br>You can create and load a new Bookmark Set at any time. The site will automatically generate a unique ID at the time of Bookmark Set creation.</p>";
            return;
        }

        function onResizer(event:Event)
        {
            doResize();
            return;
        }

        function buildLongTitle() : void
        {
            var _loc_1:String = null;
            _loc_1 = "<span class=\'myBold\'>Bookmark Set #" + myRoot.myBookmarksID + "</span><br>Created " + myRoot.bookmarksXML.@date;
            longText = new LongText(myRoot, _loc_1);
            longText.alpha = 1;
            addChild(longText);
            return;
        }

        function saveBtnRollOver(event:MouseEvent)
        {
            TweenMax.to(myLink.saveBG, fadeSpeed, {tint:myRoot.hotColor, overwrite:true});
            return;
        }

        public function fadeInShell() : void
        {
            visible = true;
            return;
        }

        function focusInListener(event:FocusEvent) : void
        {
            if (stage.displayState == StageDisplayState.FULL_SCREEN)
            {
                myRoot.closeFullscreen();
            }
            return;
        }

        function buildStyles() : void
        {
            var _loc_1:* = undefined;
            var _loc_2:* = undefined;
            var _loc_3:Object = null;
            var _loc_4:Object = null;
            var _loc_5:Object = null;
            var _loc_6:Object = null;
            var _loc_7:* = undefined;
            var _loc_8:Object = null;
            _loc_1 = new HelveticaLightEmbed().fontName;
            _loc_2 = new HelveticaBoldEmbed().fontName;
            styler = new StyleSheet();
            _loc_3 = new Object();
            _loc_3.color = myRoot.coldColorHTML;
            _loc_3.fontFamily = _loc_1;
            _loc_3.leading = -4;
            _loc_4 = new Object();
            _loc_4.color = myRoot.coldColorHTML;
            _loc_4.textDecoration = "underline";
            _loc_5 = new Object();
            _loc_5.color = myRoot.hotColorHTML;
            _loc_5.textDecoration = "underline";
            _loc_6 = new Object();
            _loc_6.color = myRoot.coldColorHTML;
            _loc_6.fontFamily = _loc_2;
            _loc_7 = new HelveticaItalicEmbed().fontName;
            _loc_8 = new Object();
            _loc_8.color = myRoot.coldColorHTML;
            _loc_8.fontFamily = _loc_7;
            styler.setStyle(".myItalic", _loc_8);
            styler.setStyle("p", _loc_3);
            styler.setStyle("a:link", _loc_4);
            styler.setStyle("a:hover", _loc_5);
            styler.setStyle(".mybold", _loc_6);
            return;
        }

        function saveBtnRollOut(event:MouseEvent)
        {
            TweenMax.to(myLink.saveBG, fadeSpeed, {tint:myRoot.coldColor, overwrite:true});
            return;
        }

    }
}
